<!--
 * @Description: 填写窗口
 * @Author: Huang Junjie
 * @Date: 2021-06-15 15:01:23
 * @LastEditTime: 2021-07-29 22:13:36
 * @LastEditors: Liu Zhiwang
-->
<template>
  <div
    v-show="popup.visible"
    class="fill-in-popup">
    <div class="title">{{ popup.title }}</div>

    <!-- 标题栏 -->
    <div class="content-header">
      <div class="content-header-vertical-bar" />
      <span class="content-header-title">接触网检修</span>
      <div class="operation-btn-div">
        <el-button
          v-if="popup.type !== 'view'"
          v-permission-button="'ITPS-ADD'"
          size="mini"
          class="operation-btn"
          icon="el-icon-plus"
          @click="addJcwRepair">新增</el-button>
      </div>
    </div>
    <!-- 标题栏 -->

    <!-- 接触网检修表格 -->
    <base-table
      :height="null"
      :loading="tableData.loading1"
      :data="tableData.tableList1"
      :columns="tableData.columns1"
      :show-index="tableData.showIndex"
      :show-selection="tableData.showSelection"
      :show-operation="tableData.showOperation"
      :show-filter-column="tableData.showFilterColumn"
      :operaton-width="tableData.operatonWidth"
      :default-operations="tableData.defaultOperations"
      :has-auth="tableData.hasAuth"
      :row-show-color="tableData.rowShowColor"
      @view="viewJcwRepair">
      <template slot="operations" slot-scope="{ row, $index }">
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-UPDATE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-edit"
          @click.stop="editJcwRepair(row, $index)" />
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-DELETE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-delete"
          @click.stop="deleteJcwRepairData(row, $index)" />
      </template>
    </base-table>
    <!-- 接触网检修表格 -->

    <!-- 标题栏 -->
    <div class="content-header">
      <div class="content-header-vertical-bar" />
      <span class="content-header-title">巡视记录</span>
      <div class="operation-btn-div">
        <el-button
          v-if="popup.type !== 'view'"
          v-permission-button="'ITPS-ADD'"
          size="mini"
          class="operation-btn"
          icon="el-icon-plus"
          @click="addMulInspect">新增</el-button>
      </div>
    </div>
    <!-- 标题栏 -->

    <!-- 巡视记录表格 -->
    <base-table
      :height="null"
      :loading="tableData.loading2"
      :data="tableData.tableList2"
      :columns="tableData.columns2"
      :show-index="tableData.showIndex"
      :show-selection="tableData.showSelection"
      :show-operation="tableData.showOperation"
      :show-filter-column="tableData.showFilterColumn"
      :operaton-width="tableData.operatonWidth"
      :default-operations="tableData.defaultOperations"
      :has-auth="tableData.hasAuth"
      :row-show-color="tableData.rowShowColor"
      @view="viewMulInspect">
      <template slot="workSpendMinutes" slot-scope="{ row }">
        {{ row.workBeginDate?row.workBeginDate:'' }}{{ row.workBeginDate?' 至 '+row.workEndDate:'' }}
      </template>
      <template slot="operations" slot-scope="{ row, $index }">
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-UPDATE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-edit"
          @click.stop="editMulInspect(row, $index)" />
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-DELETE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-delete"
          @click.stop="deleteMulInspectData(row, $index)" />
      </template>
    </base-table>
    <!-- 巡视记录表格 -->

    <!-- 标题栏 -->
    <div class="content-header">
      <div class="content-header-vertical-bar" />
      <span class="content-header-title">接触网临时计划</span>
      <div class="operation-btn-div">
        <el-button
          v-if="popup.type !== 'view'"
          v-permission-button="'ITPS-ADD'"
          size="mini"
          class="operation-btn"
          icon="el-icon-plus"
          @click="addJcwTempRepair">新增</el-button>
      </div>
    </div>
    <!-- 标题栏 -->

    <!-- 接触网临时计划表格 -->
    <base-table
      :height="null"
      :loading="tableData.loading3"
      :data="tableData.tableList3"
      :columns="tableData.columns3"
      :show-index="tableData.showIndex"
      :show-selection="tableData.showSelection"
      :show-operation="tableData.showOperation"
      :show-filter-column="tableData.showFilterColumn"
      :operaton-width="tableData.operatonWidth"
      :default-operations="tableData.defaultOperations"
      :has-auth="tableData.hasAuth"
      :row-show-color="tableData.rowShowColor"
      @view="viewJcwTempRepair">
      <template slot="operations" slot-scope="{ row, $index }">
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-UPDATE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-edit"
          @click.stop="editJcwTempRepair(row, $index)" />
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-DELETE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-delete"
          @click.stop="deleteJcwTempRepairData(row, $index)" />
      </template>
    </base-table>
    <!-- 接触网临时计划表格 -->

    <!-- 标题栏 -->
    <div class="content-header">
      <div class="content-header-vertical-bar" />
      <span class="content-header-title">其它信息</span>
      <div class="operation-btn-div">
        <el-button
          v-if="popup.type !== 'view'"
          v-permission-button="'ITPS-ADD'"
          size="mini"
          class="operation-btn"
          icon="el-icon-plus"
          @click="addOtherProblem">新增</el-button>
      </div>
    </div>
    <!-- 标题栏 -->

    <!-- 其它信息表格 -->
    <base-table
      :height="null"
      :loading="tableData.loading4"
      :data="tableData.tableList4"
      :columns="tableData.columns4"
      :show-index="tableData.showIndex"
      :show-selection="tableData.showSelection"
      :show-operation="tableData.showOperation"
      :show-filter-column="tableData.showFilterColumn"
      :operaton-width="tableData.operatonWidth"
      :default-operations="tableData.defaultOperations"
      :has-auth="tableData.hasAuth"
      :row-show-color="tableData.rowShowColor"
      @view="viewOtherProblem"
      @updateForm="editOtherProblem"
      @deleteData="deleteOtherProblemData">
      <template slot="operations" slot-scope="{ row, $index }">
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-UPDATE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-edit"
          @click.stop="editOtherProblem(row, $index)" />
        <el-button
          v-if="row.isSubmit !== 'Y' && popup.type !== 'view'"
          v-permission-button="'ITPS-DELETE'"
          class="el-icon-defined"
          size="mini"
          icon="el-icon-delete"
          @click.stop="deleteOtherProblemData(row, $index)" />
      </template>
    </base-table>
    <!-- 其它信息表格 -->

    <!-- 底部操作栏 -->
    <div class="footer">
      <el-button
        v-if="popup.type !== 'view'"
        v-permission-button="'ITPS-REPORT'"
        size="mini"
        class="footer-btn"
        type="primary"
        @click="onekeyReportData">
        一键上报
      </el-button>
      <el-button
        size="mini"
        class="footer-btn"
        @click="popup.visible = false">
        关闭
      </el-button>
    </div>
    <!-- 底部操作栏 -->

    <!-- 新增/修改接触网检修信息弹框 -->
    <AddEditJcwRepair
      :dialog="addEditJcwRepairDialog"
      :line-arr="dataList.lineArr"
      :dept-tree-arr="dataList.deptTreeArr"
      @updateData="addEditJcwRepairData" />
    <!-- 新增/修改接触网检修信息弹框 -->

    <!-- 新增/修改巡视记录信息弹框 -->
    <AddEditMulInspect
      :dialog="addEditMulInspectDialog"
      :line-arr="dataList.lineArr"
      :dept-tree-arr="dataList.deptTreeArr"
      @updateData="addEditMulInspectData" />
    <!-- 新增/修改巡视记录信息弹框 -->

    <!-- 新增/修改接触网临时计划信息弹框 -->
    <AddEditJcwTempRepair
      :dialog="addEditJcwTempRepairDialog"
      :line-arr="dataList.lineArr"
      :dept-tree-arr="dataList.deptTreeArr"
      @updateData="addEditJcwTempRepairData" />
    <!-- 新增/修改接触网临时计划信息弹框 -->

    <!-- 新增/修改其他问题信息弹框 -->
    <add-edit-other-problem
      :dialog="addEditOtherProblemDialog"
      :line-arr="dataList.lineArr"
      :dept-tree-arr="dataList.deptTreeArr"
      :dict-record-type-arr="dataList.dictRecordTypeArr"
      @updateData="addEditOtherProblemData" />
    <!-- 新增/修改其他问题信息弹框 -->

    <!-- 查看接触网检修信息弹框 -->
    <lookDataDialog
      :dialog="lookDialog" />
  </div>
</template>

<script>
import { getOtherProblemTypeDataList as getDictRecordTypeDataList, getLineList as getLineDataList, findManageDeptTree as getDeptTreeDataList } from '@/api/main'
import { getJcwRepairListPage, deleteJcwRepairData, getMulInspectListPage, deleteMulInspectData, getJcwTempRepairListPage, deleteJcwTempRepairData, getOtherProblemListPage, deleteOtherProblemData, onekeyReportData } from '@/api/jcwsc/production-daily/catenary-safety-production'
import AddEditJcwRepair from './components/AddEditJcwRepair'
import AddEditMulInspect from './components/AddEditMulInspect'
import AddEditJcwTempRepair from './components/AddEditJcwTempRepair'
import AddEditOtherProblem from './components/AddEditOtherProblem'
import lookDataDialog from './components/lookDataDialog'

export default {
  components: {
    AddEditJcwRepair,
    AddEditMulInspect,
    AddEditJcwTempRepair,
    AddEditOtherProblem,
    lookDataDialog
  },
  props: {
    // 窗口配置
    popup: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      // 下拉数据、字典
      dataList: {
        lineArr: [],
        deptTreeArr: [],
        dictRecordTypeArr: []
      },

      // 表格数组
      tableData: {
        loading1: false,
        loading2: false,
        loading3: false,
        loading4: false,
        tableList1: [],
        tableList2: [],
        tableList3: [],
        tableList4: [],
        total: 0,
        columns1: [
          { prop: 'planCode', label: '计划号', showOverflowTooltip: 'N', width: 110 },
          { prop: 'lineName', label: '线路', showOverflowTooltip: 'N', width: 110 },
          { prop: 'workRange', label: '作业区段', showOverflowTooltip: 'N' },
          { prop: 'skylightTypeText', label: '天窗类别', showOverflowTooltip: 'N', width: 110 },
          { prop: 'planTypeText', label: '计划类型', showOverflowTooltip: 'N', width: 110 },
          { prop: 'planDate', label: '日期', showOverflowTooltip: 'N', width: 110 },
          { prop: 'repairCompleteContent', label: '完成地作业内容', showOverflowTooltip: 'N' },
          { prop: 'isSubmitText', label: '状态', showOverflowTooltip: 'N', width: 90 }
        ],

        columns2: [
          { prop: 'inspectDate', label: '日期', showOverflowTooltip: 'N', width: 110 },
          { prop: 'workSpendMinutes', label: '巡视时间', showOverflowTooltip: 'N', template: true, width: 110 },
          { prop: 'deptName', label: '部门', showOverflowTooltip: 'N', width: 110 },
          { prop: 'lineName', label: '线路', showOverflowTooltip: 'N', width: 110 },
          { prop: 'inspectRange', label: '区段', showOverflowTooltip: 'N', width: 300 },
          { prop: 'dictInspectTypeName', label: '巡视类型', showOverflowTooltip: 'N', width: 110 },
          { prop: 'dictInspectWayName', label: '巡视方式', showOverflowTooltip: 'N', width: 110 },
          { prop: 'inspectContent', label: '巡视内容', showOverflowTooltip: 'N', width: 300 },
          { prop: 'inspectPeople', label: '巡视人员', showOverflowTooltip: 'N', width: 110 },
          { prop: 'inspectPersonCount', label: '巡视人数', showOverflowTooltip: 'N' },
          { prop: 'treatment', label: '巡视情况', showOverflowTooltip: 'N', width: 300 },
          { prop: 'isSubmitText', label: '状态', showOverflowTooltip: 'N', width: 90 }
        ],
        columns3: [
          { prop: 'workareaName', label: '工区', showOverflowTooltip: 'N', width: 110 },
          { prop: 'lineName', label: '线路', showOverflowTooltip: 'N', width: 110 },
          { prop: 'workRange', label: '作业区段', showOverflowTooltip: 'N' },
          { prop: 'planDate', label: '日期', showOverflowTooltip: 'N', width: 110 },
          { prop: 'repairCompleteContent', label: '完成地作业内容', showOverflowTooltip: 'N' },
          { prop: 'isSubmitText', label: '状态', showOverflowTooltip: 'N', width: 90 }
        ],
        columns4: [
          { prop: 'unitDeptName', label: '段别', showOverflowTooltip: 'N' },
          { prop: 'railTypeText', label: '铁路类型', showOverflowTooltip: 'N' },
          { prop: 'lineName', label: '线别', showOverflowTooltip: 'N' },
          { prop: 'deptName', label: '部门', showOverflowTooltip: 'N' },
          { prop: 'typeName', label: '类型', showOverflowTooltip: 'N' },
          { prop: 'disposeStatusText', label: '处理状态', showOverflowTooltip: 'N' },
          { prop: 'happenDate', label: '日期', showOverflowTooltip: 'N', width: '110' },
          { prop: 'content', label: '内容', showOverflowTooltip: 'N' },
          { prop: 'isSubmitText', label: '状态', showOverflowTooltip: 'N', width: '90' }
        ],
        showIndex: true,
        showSelection: false,
        showOperation: true,
        showFilterColumn: true,
        operatonWidth: '120px',
        defaultOperations: ['view'],
        hasAuth: true,
        rowShowColor: { name: 'name', value: 0 }
      },

      // 新增/修改接触网检修信息弹窗配置
      addEditJcwRepairDialog: {
        title: '',
        visible: false,
        disabled: false,
        loading: false,
        type: '',
        form: {},
        index: 0
      },

      // 查看接触网检修信息弹窗配置
      lookDialog: {
        title: '',
        visible: false,
        disabled: false,
        loading: false,
        type: '',
        data: [],
        index: 0
      },

      // 新增/修改巡视记录信息弹窗配置
      addEditMulInspectDialog: {
        title: '',
        visible: false,
        disabled: false,
        loading: false,
        type: '',
        form: {},
        index: 0
      },

      // 新增/修改接触网临时计划信息弹窗配置
      addEditJcwTempRepairDialog: {
        title: '',
        visible: false,
        disabled: false,
        loading: false,
        type: '',
        form: {},
        index: 0
      },

      // 新增/修改其他问题信息弹窗配置
      addEditOtherProblemDialog: {
        title: '',
        visible: false,
        disabled: false,
        loading: false,
        type: '',
        editInfo: {},
        index: 0
      }
    }
  },
  watch: {
    // 监听弹窗弹出
    'popup.visible'() {
      if (this.popup.visible === true) {
        this.tableData.tableList1 = []
        this.tableData.tableList2 = []
        this.tableData.tableList3 = []
        this.tableData.tableList4 = []
        this.getJcwRepairListPage() // 查询接触网检修列表
        this.getMulInspectListPage() // 查询巡视记录列表
        this.getJcwTempRepairListPage() // 查询接触网临时计划列表
        this.getOtherProblemListPage() // 查询其他问题信息列表
        this.getList() // 获取下拉数据、字典
      }
    }
  },
  methods: {
    // 获取下拉数据、字典
    getList() {
      this.getLineDataList() // 查询线路信息列表
      this.getDeptTreeDataList() // 查询部门数信息列表
      this.getDictRecordTypeDataList() // 查询类型信息列表
    },

    // 查询线路信息列表
    getLineDataList() {
      getLineDataList().then(res => {
        this.dataList.lineArr = res.data
      })
    },

    // 查询部门数信息列表
    getDeptTreeDataList() {
      getDeptTreeDataList().then(res => {
        const resData = res.data
        // 控制单位不可选择
        for (const i of resData) {
          if (i.obj.unitFlag === 1) { // unitFlag: 1 为单位
            i['disabled'] = true
          }
        }
        this.optionsApp = resData
        this.dataList.deptTreeArr = res.data
      })
    },

    // 查询类型信息列表
    getDictRecordTypeDataList() {
      getDictRecordTypeDataList().then(res => {
        this.dataList.dictRecordTypeArr = res.data
      })
    },

    // 查询接触网检修列表
    getJcwRepairListPage() {
      this.tableData.loading1 = true
      this.popup.params.jcwRepair.mainId = this.popup.params.mainId
      getJcwRepairListPage(this.popup.params.jcwRepair).then(res => {
        this.tableData.loading1 = false
        this.tableData.tableList1 = res.data
      }).catch(() => {
        this.tableData.loading1 = false
      })
    },

    // 查询巡视记录列表
    getMulInspectListPage() {
      this.tableData.loading2 = true
      this.popup.params.mulInspect.mainId = this.popup.params.mainId
      getMulInspectListPage(this.popup.params.mulInspect).then(res => {
        this.tableData.loading2 = false
        this.tableData.tableList2 = res.data
      }).catch(() => {
        this.tableData.loading2 = false
      })
    },

    // 查询接触网临时计划列表
    getJcwTempRepairListPage() {
      this.tableData.loading3 = true
      this.popup.params.jcwTempRepair.mainId = this.popup.params.mainId
      getJcwTempRepairListPage(this.popup.params.jcwTempRepair).then(res => {
        this.tableData.loading3 = false
        this.tableData.tableList3 = res.data
      }).catch(() => {
        this.tableData.loading3 = false
      })
    },

    // 查询其他问题信息列表
    getOtherProblemListPage() {
      this.tableData.loading4 = true
      this.popup.params.otherProblem.mainId = this.popup.params.mainId
      getOtherProblemListPage(this.popup.params.otherProblem).then(res => {
        this.tableData.loading4 = false
        this.tableData.tableList4 = res.data
      }).catch(() => {
        this.tableData.loading4 = false
      })
    },

    // 打开查看接触网检修信息弹框
    viewJcwRepair(row) {
      this.lookDialog.title = '查看接触网检修信息'
      this.lookDialog.visible = true
      this.lookDialog.type = 'view'
      this.lookDialog.disabled = true
      this.lookDialog.form = row
      this.lookDialog.data = [
        { column1: '计划日期',
          column2: row.planDate,
          column3: '计划号',
          column4: row.planCode,
          column5: '工区',
          column6: row.workareaName,
          type: 'text'
        },
        { column1: '线路',
          column2: row.lineName,
          column3: '行别',
          column4: row.directionName,
          column5: '天窗类别',
          column6: row.skylightTypeText,
          type: 'text'
        },
        { column1: '盯控干部',
          column2: row.leaderName,
          column3: '盯控干部电话',
          column4: row.leaderPhone,
          column5: '申请时间',
          column6: row.applySpendMinutes ? row.applyStartTime + ' 至 ' + row.applyEndTime + '（' + row.applySpendMinutes + '分钟）' : '',
          type: 'text'
        },
        { column1: '计划类型',
          column2: row.planTypeText,
          column3: '跟班领导',
          column4: row.followLeader,
          column5: '跟班领导电话',
          column6: row.followLeaderPhone,
          type: 'text'
        },
        { column1: '施工单位',
          column2: row.constructInfo,
          column3: '跟班干部',
          column4: row.followCadreName,
          column5: '跟班干部电话',
          column6: row.followCadrePhone,
          type: 'text'
        },
        { column1: '作业区段',
          column2: row.workRange,
          type: 'textarea'
        },
        { column1: '停电范围',
          column2: row.stopPowerRange,
          type: 'textarea'
        },
        { column1: '工作票号',
          column2: row.workNo,
          column3: '计划状态',
          column4: row.repairPlanStatusText,
          column5: '取消原因',
          column6: row.dictCancelReasonName,
          type: 'text'
        },
        { column1: '行调给点时间',
          column2: row.xdSpendMinutes ? row.xdBeginDate + ' 至 ' + row.xdEndDate + '（' + row.xdSpendMinutes + '分钟）' : '',
          column3: '电调给点时间',
          column4: row.ddSpendMinutes ? row.ddEndDate + ' 至 ' + row.ddBeginDate + '（' + row.ddSpendMinutes + '分钟）' : '',
          column5: '检修时间',
          column6: row.repairSpendMinutes ? row.repairBeginDate + ' 至 ' + row.repairEndDate + '（' + row.repairSpendMinutes + '分钟）' : '',
          type: 'text'
        },
        { column1: '检修列',
          column2: row.repairCol,
          column3: '梯车数',
          column4: row.ladderCarCount,
          column5: '轨道车数',
          column6: row.railCarCount,
          type: 'text'
        },
        { column1: '人工组数',
          column2: row.repairPeopleGroupCount,
          column3: '作业人数',
          column4: row.repairPeopleCount,
          column5: '作业量(条公里)',
          column6: row.repairAmount,
          type: 'text'
        },
        { column1: '地线组',
          column2: row.groundWireGoup,
          column3: '',
          column4: '',
          column5: '',
          column6: '',
          type: 'text'
        },
        { column1: '作业完成内容',
          column2: row.repairCompleteContent,
          type: 'textarea'
        },
        { column1: '备注',
          column2: row.memo,
          type: 'textarea'
        }
      ]
    },

    // 打开新增接触网检修检修信息弹框
    addJcwRepair() {
      var addEditJcwRepairDialog = {
        title: '新增接触网检修信息',
        visible: true,
        type: 'add',
        disabled: false,
        deptCode: this.popup.params.deptCode,
        form: {
          mainId: this.popup.params.mainId,
          planDate: this.popup.uploadDate,
          applySpendMinutes: '',
          xdSpendMinutes: '',
          ddSpendMinutes: '',
          repairSpendMinutes: '',
          leaderName: '',
          followLeader: '',
          directionAttr: [],
          filesList: [],
          status: '1',
          delFlag: 0
        }
      }
      this.addEditJcwRepairDialog = Object.assign(this.addEditJcwRepairDialog, addEditJcwRepairDialog)
    },

    // 打开修改接触网检修信息弹框
    editJcwRepair(row, index) {
      var addEditJcwRepairDialog = {
        title: '修改接触网检修信息',
        visible: true,
        type: 'edit',
        disabled: false,
        index: index,
        deptCode: this.popup.params.deptCode,
        form: JSON.parse(JSON.stringify(row))
      }
      this.addEditJcwRepairDialog = Object.assign(this.addEditJcwRepairDialog, addEditJcwRepairDialog)
    },

    // 新增、修改接触网检信息子组件保存触发列表更新
    addEditJcwRepairData(res) {
      this.notifiySuccess('保存成功！')
      this.getJcwRepairListPage() // 查询接触网检修信息列表
      this.addEditJcwRepairDialog.visible = false
    },

    // 删除接触网检修信息
    deleteJcwRepairData(row, index) {
      this.$confirm('此操作将删除该接触网检修信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteJcwRepairData(row.id).then(() => {
          this.notifiySuccess('删除成功!')
          this.tableData.tableList1.splice(index, 1)
        })
      }).catch(() => {
        this.notifiyInfo('已取消操作!')
      })
    },

    // 打开查看巡视记录信息弹框
    viewMulInspect(row) {
      this.lookDialog.title = '查看巡视记录信息'
      this.lookDialog.visible = true
      this.lookDialog.type = 'view'
      this.lookDialog.disabled = true
      this.lookDialog.form = row
      this.lookDialog.data = [
        { column1: '巡视日期',
          column2: row.inspectDate,
          column3: '线路',
          column4: row.lineName,
          column5: '部门',
          column6: row.deptName,
          type: 'text'
        },
        { column1: '作业时间',
          column2: row.workSpendMinutes ? row.workBeginDate + ' 至 ' + row.workEndDate + '（' + row.workSpendMinutes + '分钟）' : '',
          column3: '巡视类型',
          column4: row.dictInspectTypeName,
          column5: '作业领导人',
          column6: row.workLeader,
          type: 'text'
        },
        { column1: '跟班领导',
          column2: row.followLeader,
          column3: '跟班领导电话',
          column4: row.followLeaderPhone,
          column5: '巡视人员',
          column6: row.inspectPeople,
          type: 'text'
        },
        { column1: '跟班干部',
          column2: row.followCadre,
          column3: '跟班干部电话',
          column4: row.followCadrePhone,
          column5: '',
          column6: '',
          type: 'text'
        },
        { column1: '巡视区段',
          column2: row.inspectRange,
          type: 'textarea'
        },
        { column1: '巡视内容',
          column2: row.inspectContent,
          type: 'textarea'
        },
        { column1: '巡视方式',
          column2: row.dictInspectWayName,
          column3: '总人数',
          column4: row.inspectPersonCount,
          column5: '是否异常',
          column6: row.isNormal === 'NO' ? '否' : '是',
          type: 'text'
        },
        { column1: '司机',
          column2: row.driver,
          column3: '车号/车次',
          column4: row.inspectTrainNum,
          column5: '',
          column6: '',
          type: 'text'
        },
        { column1: '存在问题',
          column2: row.problemContent,
          type: 'textarea'
        },
        { column1: '处理情况',
          column2: row.treatment,
          type: 'textarea'
        },
        { column1: '备注',
          column2: row.memo,
          type: 'textarea'
        }
      ]
    },

    // 打开新增巡视记录信息弹框
    addMulInspect() {
      var addEditMulInspectDialog = {
        title: '新增巡视记录信息',
        visible: true,
        type: 'add',
        disabled: false,
        deptCode: this.popup.params.deptCode,
        form: {
          mainId: this.popup.params.mainId,
          inspectDate: this.popup.uploadDate,
          workSpendMinutes: '',
          followLeader: '',
          followCadre: '',
          workLeader: '',
          inspectPeopleList: [],
          filesList: [],
          status: '1',
          delFlag: 0
        }
      }
      this.addEditMulInspectDialog = Object.assign(this.addEditMulInspectDialog, addEditMulInspectDialog)
    },

    // 打开修改巡视记录信息弹框
    editMulInspect(row, index) {
      var addEditMulInspectDialog = {
        title: '修改巡视记录信息',
        visible: true,
        type: 'edit',
        disabled: false,
        index: index,
        deptCode: this.popup.params.deptCode,
        form: JSON.parse(JSON.stringify(row))
      }
      this.addEditMulInspectDialog = Object.assign(this.addEditMulInspectDialog, addEditMulInspectDialog)
    },

    // 新增、修改巡视记录信息子组件保存触发列表更新
    addEditMulInspectData(res) {
      this.notifiySuccess('保存成功！')
      this.getMulInspectListPage() // 查询巡视记录信息列表
      this.addEditMulInspectDialog.visible = false
    },

    // 删除巡视记录信息
    deleteMulInspectData(row, index) {
      this.$confirm('此操作将删除该巡视记录信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteMulInspectData(row.id).then(() => {
          this.notifiySuccess('删除成功!')
          this.tableData.tableList2.splice(index, 1)
        })
      }).catch(() => {
        this.notifiyInfo('已取消操作!')
      })
    },

    // 打开查看接触网临时计划信息弹框
    viewJcwTempRepair(row) {
      this.lookDialog.title = '查看接触网临时计划信息'
      this.lookDialog.visible = true
      this.lookDialog.type = 'view'
      this.lookDialog.disabled = true
      this.lookDialog.form = row
      this.lookDialog.data = [
        { column1: '计划日期',
          column2: row.planDate,
          column3: '作业工区',
          column4: row.workareaName,
          column5: '线路',
          column6: row.lineName,
          type: 'text'
        },
        { column1: '行别',
          column2: row.directionName,
          column3: '申请时间',
          column4: row.blockMinute ? row.blockStartTime + ' 至 ' + row.blockEndTime + '（' + row.blockMinute + '分钟）' : '',
          column5: '施工等级',
          column6: row.dictWorkGradeName,
          type: 'text'
        },
        { column1: '盯控干部',
          column2: row.leaderName,
          column3: '盯控干部电话',
          column4: row.leaderPhone,
          column5: '登记站',
          column6: row.registerSite,
          type: 'text'
        },
        { column1: '联络员',
          column2: row.liaisonMan,
          column3: '联络员电话',
          column4: row.liaisonManPhone,
          column5: '主体单位',
          column6: row.mainUnitName,
          type: 'text'
        },
        { column1: '施工负责人',
          column2: row.workPrincipalPerson,
          column3: '施工负责人电话',
          column4: row.workPrincipalPersonPhone,
          column5: '施工项目',
          column6: row.workProject,
          type: 'text'
        },
        { column1: '限速条件(里程、长度、要求)',
          column2: row.limitCondition,
          type: 'textarea'
        },
        { column1: '行车方式（变化）',
          column2: row.trafficWay,
          type: 'textarea'
        },
        { column1: '设备变化',
          column2: row.equipmentVariation,
          type: 'textarea'
        },
        { column1: '动车组运行条件',
          column2: row.runCondition,
          type: 'textarea'
        },
        { column1: '其它事项',
          column2: row.otherMatter,
          type: 'textarea'
        },
        { column1: '作业车运行占用股道',
          column2: row.jobRunTrackOccupied,
          type: 'textarea'
        },
        { column1: '滚动施工需取消的前次限速（命令号码）',
          column2: row.cancelCommandNum,
          type: 'textarea'
        },
        { column1: '施工里程',
          column2: row.workMileage,
          type: 'textarea'
        },
        { column1: '作业区段',
          column2: row.workRange,
          type: 'textarea'
        },
        { column1: '停电范围',
          column2: row.stopPowerRange,
          type: 'textarea'
        },
        { column1: '行调给点时间',
          column2: row.xdSpendMinutes ? row.xdBeginDate + ' 至 ' + row.xdEndDate + '（' + row.xdSpendMinutes + '分钟）' : '',
          column3: '电调给点时间',
          column4: row.ddSpendMinutes ? row.ddEndDate + ' 至 ' + row.ddBeginDate + '（' + row.ddSpendMinutes + '分钟）' : '',
          column5: '检修时间',
          column6: row.repairSpendMinutes ? row.repairBeginDate + ' 至 ' + row.repairEndDate + '（' + row.repairSpendMinutes + '分钟）' : '',
          type: 'text'
        },
        { column1: '检修列',
          column2: row.repairCol,
          column3: '梯车数',
          column4: row.ladderCarCount,
          column5: '轨道车数',
          column6: row.railCarCount,
          type: 'text'
        },
        { column1: '人工组数',
          column2: row.repairPeopleGroupCount,
          column3: '作业人数',
          column4: row.repairPeopleCount,
          column5: '作业量(条公里)',
          column6: row.repairAmount,
          type: 'text'
        },
        { column1: '作业完成内容',
          column2: row.repairCompleteContent,
          type: 'textarea'
        },
        { column1: '备注',
          column2: row.memo,
          type: 'textarea'
        }
      ]
    },

    // 打开新增接触网临时计划信息弹框
    addJcwTempRepair() {
      var addEditJcwTempRepairDialog = {
        title: '新增接触网临时计划信息',
        visible: true,
        type: 'add',
        disabled: false,
        deptCode: this.popup.params.deptCode,
        form: {
          mainId: this.popup.params.mainId,
          planDate: this.popup.uploadDate,
          blockMinute: '',
          xdSpendMinutes: '',
          ddSpendMinutes: '',
          repairSpendMinutes: '',
          leaderName: '',
          liaisonManPhone: '',
          workPrincipalPerson: '',
          directionAttr: [],
          filesList: [],
          status: '1',
          delFlag: 0
        }
      }
      this.addEditJcwTempRepairDialog = Object.assign(this.addEditJcwTempRepairDialog, addEditJcwTempRepairDialog)
    },

    // 打开修改接触网临时计划信息弹框
    editJcwTempRepair(row, index) {
      var addEditJcwTempRepairDialog = {
        title: '修改接触网临时计划信息',
        visible: true,
        type: 'edit',
        disabled: false,
        index: index,
        deptCode: this.popup.params.deptCode,
        form: JSON.parse(JSON.stringify(row))
      }
      this.addEditJcwTempRepairDialog = Object.assign(this.addEditJcwTempRepairDialog, addEditJcwTempRepairDialog)
    },

    // 新增、修改接触网临时计划信息子组件保存触发列表更新
    addEditJcwTempRepairData(res) {
      this.notifiySuccess('保存成功！')
      this.getJcwTempRepairListPage() // 查询接触网临时计划信息列表
      this.addEditJcwTempRepairDialog.visible = false
    },

    // 删除接触网临时计划信息
    deleteJcwTempRepairData(row, index) {
      this.$confirm('此操作将删除该接触网临时计划信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteJcwTempRepairData(row.id).then(() => {
          this.notifiySuccess('删除成功!')
          this.tableData.tableList1.splice(index, 1)
        })
      }).catch(() => {
        this.notifiyInfo('已取消操作!')
      })
    },

    // 打开查看其他问题信息弹框
    viewOtherProblem(row) {
      this.lookDialog.title = '查看其他问题信息'
      this.lookDialog.visible = true
      this.lookDialog.type = 'view'
      this.lookDialog.disabled = true
      this.lookDialog.form = row
      this.lookDialog.data = [
        { column1: '日期',
          column2: row.happenDate,
          column3: '线路',
          column4: row.lineName,
          column5: '部门',
          column6: row.deptName,
          type: 'text'
        },
        { column1: '类型',
          column2: row.bizDailyOtherInfoTypeId,
          column3: '处理状态',
          column4: row.disposeStatus === 'NO' ? '未处理' : '已处理',
          column5: '处理日期',
          column6: row.disposeDate,
          type: 'text'
        },
        { column1: '内容',
          column2: row.content,
          type: 'textarea'
        },
        { column1: '处理情况',
          column2: row.condition,
          type: 'textarea'
        },
        { column1: '备注',
          column2: row.memo,
          type: 'textarea'
        }
      ]
    },

    //  打开新增其他问题信息弹框
    addOtherProblem() {
      this.addEditOtherProblemDialog.title = '新增其他问题信息'
      this.addEditOtherProblemDialog.visible = true
      this.addEditOtherProblemDialog.type = 'add'
      this.addEditOtherProblemDialog.deptCode = this.popup.params.deptCode
      this.addEditOtherProblemDialog.editInfo = {
        uploadDate: this.popup.uploadDate,
        mainId: this.popup.params.mainId
      }
    },

    // 打开修改其他问题信息弹框
    editOtherProblem(row, index) {
      this.addEditOtherProblemDialog.title = '修改其他问题信息'
      this.addEditOtherProblemDialog.visible = true
      this.addEditOtherProblemDialog.type = 'edit'
      this.addEditOtherProblemDialog.editInfo = row
      this.addEditOtherProblemDialog.index = index
      this.addEditOtherProblemDialog.deptCode = this.popup.params.deptCode
    },

    // 新增、修改其他问题信息子组件保存触发列表更新
    addEditOtherProblemData(res) {
      this.notifiySuccess('保存成功！')
      this.getOtherProblemListPage() // 查询其他问题信息列表
      // if (this.addEditOtherProblemDialog.type === 'add') {
      //   this.tableData.tableList2.unshift(res)
      // } else if (this.addEditOtherProblemDialog.type === 'edit') {
      //   this.$set(this.tableData.tableList2, this.addEditOtherProblemDialog.index, res)
      // }
      this.addEditOtherProblemDialog.visible = false
    },

    // 删除其他问题信息
    deleteOtherProblemData(row, index) {
      this.$confirm('此操作将删除该其他问题信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteOtherProblemData(row.id).then(() => {
          this.notifiySuccess('删除成功!')
          this.tableData.tableList4.splice(index, 1)
        })
      }).catch(() => {
        this.notifiyInfo('已取消操作!')
      })
    },

    // 接触网安全生产一键上报
    onekeyReportData() {
      this.$confirm('此操作将一键上报该接触网安全生产日报, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const data = {
          mainId: this.popup.params.mainId,
          dailyType: 'JCW',
          jcwIdList: [],
          mulInspectIdList: [],
          jcwTempIdList: [],
          otherIdList: [],
          dayReportDatetime: this.popup.params.otherProblem.happenDate
        }
        this.tableData.tableList1.forEach(val => {
          if (val.isSubmit !== 'Y' && val.isSubmit !== 'T') {
            data.jcwIdList.push(val.id)
          }
        })
        this.tableData.tableList2.forEach(val => {
          if (val.isSubmit !== 'Y') {
            data.mulInspectIdList.push(val.id)
          }
        })
        this.tableData.tableList3.forEach(val => {
          if (val.isSubmit !== 'Y') {
            data.jcwTempIdList.push(val.id)
          }
        })
        this.tableData.tableList4.forEach(val => {
          if (val.isSubmit !== 'Y') {
            data.otherIdList.push(val.id)
          }
        })
        onekeyReportData(data).then(res => {
          this.$emit('updateData', res.data)
        })
      }).catch(() => {
        this.notifiyInfo('已取消操作!')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.fill-in-popup {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 36px;
  padding: 15px 15px 15px 15px;
  background-color: #F1F4FB;
  overflow: auto;
  .title {
    text-align: center;
    font-size: 24px;
    font-weight: 500;
  }
  .content-header {
    margin: 10px;
    height: 36px;
    display: flex;
    align-items: center;
    .content-header-vertical-bar {
      width: 7px;
      height: 26px;
      background: #409eff;
      border-radius: 4px;
      margin-right: 13px;
    }
    .content-header-title {
      font-size: 20px;
    }
    .operation-btn {
      margin-left: 20px;
    }
  }
  .footer {
    position: fixed;
    left: 278px;
    right: 0;
    bottom: 0;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    .footer-btn {
      margin: 5px;
    }
  }
}
</style>
